<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>axios使用</title>
    <link crossorigin="anonymous" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script crossorigin="anonymous" src="https://cdn.bootcss.com/axios/0.19.2/axios.min.js"></script>
</head>

<body>
    <div class="container">
        <h2 class="page-header">独立方法使用</h2>
        <button class="btn btn-primary" onclick="sendGET()"> 发送 GET 请求 </button>
        <button class="btn btn-warning" onclick="sendPOST()"> 发送POST请求 </button>
        <button class="btn btn-success" onclick="sendPUT()"> 发送 PUT 请求 </button>
        <button class="btn btn-info" onclick="sendPatch()"> 发送 PATCH 请求 </button>
        <button class="btn btn-danger" onclick="sendDELETE()"> 发送 DELETE 请求 </button>
    </div>
    <script>
        //
        function sendGET(){
            axios.get('http://127.0.0.1/server', {
                params: {a:100,b:200},
                headers: {c:300,d:400}
            }).then(response => {
                console.log(response);
            })
        }

        function sendPOST(){
            axios
            .post('http://127.0.0.1/server', {a:100,b:200}, {
                params: {c:400, f:500},
                headers: {x:1, y:2}
            })
            .then(response => {
                console.log(response);
            })
        }
    </script>
</body>

</html>